# if guess == 8:
#     print('猜对了！')
# else:
#     if guess > 8:
#         print('大了！')
#     else :
#         print('小了！')
# print('5游戏结束！')
import random
secret = random.randint(1,10)
def guess(x,y):
    while x > secret:
        print('大了！')
        y =y-1
        return y
    while x < secret:
        print('小了！')
        y=y-1
        return y
    # while x==8:
    print('猜对了！')
    y=0
    return y
n=3
while n != 0:
        print('您有%s次机会！'%n)
        ss = input('请输入一个数字：')
        if not ss.isdigit() :
            print('输入不合法！')
        while ss  not in ['1','2','3','4','5','6','7','8','9','10']:
            print('请输入1-10之间的整数！')
            ss = input('请输入一个数字：')
        xx = int(ss)
        n=guess(xx,n)
print('游戏结束！')

